package ut.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
public class Login extends HttpServlet{
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		request.setCharacterEncoding("utf-8");
		// 取得並驗證使用者輸入資訊
		String email, password;
		if(request.getParameter("email") == null || request.getParameter("password") == null){
			return;
		}else{
			email = request.getParameter("email");
			password = request.getParameter("password");
		}
		// 將新的使用者加入資料庫
		response.setIntHeader("result", ut.data.User.login(email, password, request.getSession())); // -1: 系統錯誤、0: 失敗、1: 成功
	}
}